package com.dxy.shardingjdbc.controller;



import cn.hutool.core.lang.Assert;
import com.dxy.shardingjdbc.model.po.Company;
import com.dxy.shardingjdbc.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;
import java.util.List;

/**
 * 企业表(Company)表控制层
 *
 * @author dangxianyue
 * @since 2023-02-02 17:32:25
 */
@Api(tags = "企业接口")
@RestController
@RequestMapping("company")
public class CompanyController {

    @Resource
    private CompanyService companyService;

    @ApiOperation("新增企业")
    @PostMapping("/save")
    public Company save(String name) {
        Assert.notBlank(name);
        Company company = new Company().setName(name);
        companyService.save(company);
        return company;
    }

    @ApiOperation("企业列表")
    @GetMapping("/list")
    public List<Company> list() {
        return companyService.list();
    }

}

